package licode.unisop.types.dp;

import lombok.Getter;

/**
 * 认证类型
 *
 * @author licode
 */
@Getter
public class AuthType {

    public static final AuthType PASSWORD = new AuthType("password");
    public static final AuthType FACE = new AuthType("face");
    public static final AuthType EMAIL = new AuthType("email");
    public static final AuthType SMS_CODE = new AuthType("sms-code");
    public static final AuthType WX_AUTH = new AuthType("wx-auth");

    private final String type;

    private AuthType(String type) {
        this.type = type;
    }

    public static AuthType build(String type) {
        if (AuthType.EMAIL.type.equals(type)) {
            return AuthType.EMAIL;
        } else if (AuthType.SMS_CODE.type.equals(type)) {
            return AuthType.SMS_CODE;
        }
        return AuthType.PASSWORD;
    }

    public boolean isPassword() {
        return AuthType.PASSWORD.type.equals(type);
    }

    public boolean isEmail() {
        return AuthType.EMAIL.type.equals(type);
    }

    public boolean isSmsCode() {
        return AuthType.SMS_CODE.type.equals(type);
    }

    @Override
    public String toString() {
        return type + "";
    }
}
